package com.ck.controller.teacher;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.ck.domain.Chapter;
import com.ck.domain.Student;
import com.ck.service.QuestionService;

public class ShowChapterInfoController extends AbstractController {
	
	private QuestionService questionService;

	public void setQuestionService(QuestionService questionService) {
		this.questionService = questionService;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		Integer chapterID = Integer.parseInt(request.getParameter("chapterID"));
		Chapter chapter = questionService.gainChapter(chapterID);
		
		String subject_name = questionService.gainSubject(chapter.getSubject()).getName();
		
		Map model = new HashMap();
		model.put("chapter", chapter);
		model.put("subject_name", subject_name);
		
		return new ModelAndView("teacher/showChapterInfo", model);
	}

}
